<?php

namespace app\controller;

use app\BaseController;
use think\Request;
use app\service\PayablesService;
use Exception;


class Payables extends BaseController
{    
    protected $middleware = [
        \app\middleware\LoginCheck::class
    ];
    protected $request;
    protected $payablesService;
    public function __construct(Request $request,PayablesService $payablesService)
    {       
        $this->request = $request;
        $this->payablesService = $payablesService;
    }   
   

    public function list()
    {       
        try {   
            $params = $this->request->param();            
            $data = $this->payablesService->list($params);
        } catch (Exception $e) {
            return $this->error($e->getMessage());
        }

        return $this->success($data);
    }

    public function review()
    {       
        try {   
            $params = json_decode(file_get_contents('php://input'),true);         
            $data = $this->payablesService->review($params);
        } catch (Exception $e) {
            return $this->error($e->getMessage());
        }

        return $this->success($data);
    }
    public function cancel_review()
    {       
        try {   
            $params = json_decode(file_get_contents('php://input'),true);   
            $data = $this->payablesService->cancel_review($params);
        } catch (Exception $e) {
            return $this->error($e->getMessage());
        }

        return $this->success($data);
    }

    public function create_all()
    {       
        try {   
            $params = json_decode(file_get_contents('php://input'),true);     
            $data = $this->payablesService->create_all($params);
        } catch (Exception $e) {
            return $this->error($e->getMessage());
        }

        return $this->success($data);
    }
   
}
